home *** CD-ROM | disk | FTP | other *** search
- /* k 0184 18/06/91 */
- /* k 0189 27/06/91 */
- /* k 0190 28/06/91 */
- /* k 0199 18/08/91 *//* OS_TYPE */
- /* k 0199 */
- /* k 0222 18/09/91 */
- /* k 0224 23/09/91 *//* ebss */
- /* k 0230 09/10/91 *//* assemble some data */
- #include <ebss.h> /* @0224 */
- #if (OVL_TYPE!=1)
- #include <stdlib.h>
- #include <stdio.h>
- #include <fcntl.h> /* @0184 */
- #include <string.h>
- #endif
- #if ((OS_TYPE!=3)&&(OS_TYPE!=4))
- #endif /* @0184 */
- #include "pconio.h"
-
- #if (OS_TYPE==4)
- #include <sys/machdep.h>
- #include <sgtty.h>
- #include <sys/comcrt.h>
- #define sotofar(seg, off) (((char far *) (((long)(unsigned) (seg)) << 16)) + (unsigned) (off))
- #endif
- /* @0230 */
- #define MK_FP(seg,ofs) ((void far *) \
- (((unsigned long)(seg) << 16) | (unsigned)(ofs)))
- #define FP_SEG(fp) ((unsigned)(void _seg *)(void far *)(fp))
- #define FP_OFF(fp) ((unsigned)(fp))
-
- void writef(); /* @0184 */
- void setcolor(); /* @0184 */
- void setcursor(); /* @0184 */
- unsigned int getcursor(); /* @0184 */
- void changecursor(); /* @0184 */
- void initcursor(); /* @0184 */
- void initcolortable(); /* @0184 */
-
- #if ((OS_TYPE==3) || (OS_TYPE==4))
- unsigned iint adaptIO,adaptMD,adaptMAP;
- char far *videobuf;
- #endif
-
-
-
- int check_mode ( ) {
- #if ((OS_TYPE!=3)&&(OS_TYPE!=4))
- struct text_info ti;
-
- union REGS reg;
-
- reg.h.ah = 15;
- #if ((OVL_TYPE==1)&&(RESIDENT!=1))
- Res_int86(0X10, ®, ®);
- #else
- int86(0X10, ®, ®);
- #endif
- if (reg.h.al==7) return 0;
- return 1;
- #elif (OS_TYPE==3)
- #define TCGMODE ('T'<<8|10)
- struct tty_mode {
- unsigned char tm_cap
- unsigned char tm_adaptor;
- unsigned char tm_colmode;
- unsigned char tm_colsel;
- } mode;
- ioctl (0,TCGMODE,&mode);
- return (mode.tm_adaptor); /* 0 - MONO */
- #elif (OS_TYPE==4)
- if ( ioctl (0,CONS_GET,0)==MONO)
- return 0;
- return 1;
- #endif
- }
-
-
-
-
- void outscreen(buf,offset,len)
- char *buf; /* @0184 */
- int offset; /* @0184 */
- int len; /* @0184 */
- {
- char far *pt;
- int j,i=2*offset;
- char *w=buf+i;
- #if (OS_TYPE==4)
- pt=videobuf+i;
- #else
- pt=MK_FP(vissegment,i);
- #endif
- for (j=0;j<2*len;j++)
- *pt++=*w++;
- /* movedata(FP_SEG(buf+i),FP_OFF(buf+i),vissegment,i,2*len); */
- }
-
- void inscreen(buf,offset,len)
- char *buf; /* @0184 */
- int offset; /* @0184 */
- int len; /* @0184 */
- {
- char far *pt;
- int j,i=2*offset;
- char far *w=buf+i;
- #if (OS_TYPE==4)
- pt=videobuf+i;
- #else
- pt=MK_FP(vissegment,i);
- #endif
- for (j=0;j<2*len;j++)
- *w++=*pt++;
- }
-
- void setcursor(shape) /* @0184 */
- unsigned int shape; /* @0184 */
- /* Sets the shape of the cursor */
- {
- #if ((OS_TYPE !=3)&&(OS_TYPE!=4))
- union REGS reg;
-
- reg.h.ah = 1;
- reg.x.cx = shape;
- #if ((OVL_TYPE==1)&&(RESIDENT!=1))
- Res_int86(0X10, ®, ®);
- #else
- int86(0X10, ®, ®);
- #endif
- #else
- #if ((OS_TYPE==3)||(OS_TYPE==0))
- unsigned char b1=shape & 0xFF;
- unsigned char b2=shape >> 8;
- #if ((OVL_TYPE==1)&&(RESIDENT!=1))
- Res_outp (baseport,0x0b);
- Res_outp (baseport+1,b1);
- Res_outp (baseport,0x0a);
- Res_outp (baseport+1,b2);
- #else
- outp (baseport,0x0b);
- outp (baseport+1,b1);
- outp (baseport,0x0a);
- outp (baseport+1,b2);
- #endif
- #else
- struct port_io_arg depoz;
- unsigned char b1=shape & 0xFF;
- unsigned char b2=shape >> 8;
- depoz.args[0].dir=OUT_ON_PORT;
- depoz.args[0].port=baseport;
- depoz.args[0].data=0x0b;
- depoz.args[1].dir=OUT_ON_PORT;
- depoz.args[1].port=baseport+1;
- depoz.args[1].data=b1;
- depoz.args[2].dir=OUT_ON_PORT;
- depoz.args[2].port=baseport;
- depoz.args[2].data=0x0a;
- depoz.args[3].dir=OUT_ON_PORT;
- depoz.args[3].port=baseport+1;
- depoz.args[3].data=b2;
- ioctl (0,adaptIO,&depoz);
- #endif
- #endif
- } /* setcursor */
-
- unsigned int getcursor() /* @0184 */
- /* Returns the shape of the current cursor */
- {
- #if ((OS_TYPE !=3)&&(OS_TYPE!=4))
- union REGS reg;
-
- reg.h.ah = 3;
- reg.h.bh = 0;
- #if ((OVL_TYPE==1)&&(RESIDENT!=1))
- Res_int86(0X10, ®, ®);
- #else
- int86(0X10, ®, ®);
- #endif
- return(reg.x.cx);
- #else
- if (check_mode()) return (0x0607);
- else return (0x0A0C);
- #endif
- } /* getcursor */
-
-
- void setcolor(color) /* @0184 */
- int color; /* @0184 */
- /* Sets the current color using the color table */
- {
- textattr(colortable[color]);
- } /* setcolor */
-
-
- void writef(col,row,color,width,string) /* @0184 */
- int col; /* @0184 */
- int row; /* @0184 */
- int color; /* @0184 */
- int width; /* @0184 */
- char * string; /* @0184 */
- /* Prints a string in video memory at a selected location in a color */
- {
- char output[81],*ppp; int i,j;
-
- #if ((OVL_TYPE==1)&&(RESIDENT!=1))
- int len=Res_strlen(string);
- #else
- int len=strlen(string);
- #endif
- if (len>80) len=80;
- #if ((OVL_TYPE==1)&&(RESIDENT!=1))
- Res_memcpy (output, string, len);
- #else
- memcpy (output, string, len);
- #endif
- output[width] = 0;
- if (len < width) {
- j=width-len;
- ppp=output+len;
- for (i=0;i<j;i++)
- *ppp++=' ';
- }
- setcolor(color);
- gotoxy(col, row);
- cprintf(output);
- return;
- } /* writef */
-
- void changecursor(insmode)
- /* Changes the cursor shape based on the current insert mode */
- {
- if (insmode)
- setcursor(tallcursor);
- else
- setcursor(shortcursor);
- } /* changecursor */
-
- #if (OS_TYPE==4)
- sh_vt() /* @0190 */
- { /* @0190 */
- struct sgttyb argum; /* @0190 */
- gtty(0,&argum); /* @0190 */
- argum.sg_flags|=RAW; /* @0190 */
- argum.sg_flags&=~ECHO; /* @0190 */
- stty(0,&argum); /* @0190 */
- } /* @0190 */
- vt_sh() /* @0190 */
- { /* @0190 */
- struct sgttyb argum; /* @0190 */
- gtty(0,&argum); /* @0190 */
- argum.sg_flags&=~RAW; /* @0190 */
- argum.sg_flags|=ECHO; /* @0190 */
- stty(0,&argum); /* @0190 */
- } /* @0190 */
- #endif